package sdp.group14.views;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import sdp.group14.R;
import sdp.group14.appdata.Request;

/**
 * this class is to bind the each single list view in the history
 * activity with the defined layout Request_list_item
 * @author ste706
 *
 */
public class TenantRequestListItem extends LinearLayout {
	
	private Request request;
	private TextView address_text;
	private ImageButton navigate_btn;

	public TenantRequestListItem(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	/**
	 * register with the views in the xml file
	 */
	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		address_text = (TextView)findViewById(R.id.tenant_text_requestInfo);
		navigate_btn = (ImageButton)findViewById(R.id.tenant_btn_delete);
	}

	/**
	 * set the text in the list view to display the Request's information
	 * @param Request
	 */
	public void setRequest(Request request) {
		this.request = request;
		address_text.setText("Date: "+request.getreqDate() + "\nItem: " + request.getreqCategory()+ "\nStatus: " + request.getreqStatus() + "\nDescription: " + request.getreqDescription());
		navigate_btn.setTag(request);
		address_text.setTag(request);
	}

	public Request getRequest() {
		return request;
	}

}
